<!DOCTYPE html>
<html lang="en">
<!--header-->
<include file="Public:header"/>
<!--header-->
<section id="main-content">
    <section class="wrapper">
        <h3><i class="fa fa-angle-right"></i> 添加/修改信息</h3>

        <!-- BASIC FORM ELELEMNTS -->
        <div class="row mt">
            <div class="col-lg-12">
                <div class="form-panel">
                    <h4 class="mb">
                        <i class="fa fa-angle-right"></i> 轮播图信息
                        <a class="btn btn-theme btn-default" href="{:U('index')}">返回</a>
                    </h4>

                    <form id="myForm" class="form-horizontal style-form" method="post" action="{:U('add')}"  enctype="multipart/form-data">
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">轮播图位置</label>
                            <div class="col-sm-10">
                                <!--1 商品 2资讯  3会员卡  4攻略课堂 5线上报名 6题库-->
                                <select name="type" class="form-control">
                                    <option value="1" <if condition="$list['type'] == 1">selected </if> >小程序首页</option>
                                    <option value="2" <if condition="$list['type'] == 2">selected </if> >小程序会员卡页</option>
                                    <option value="3" <if condition="$list['type'] == 3">selected </if> >小程序测试题页</option>
                                    <option value="4" <if condition="$list['type'] == 4">selected </if> >小程序商城页</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group" id="fa">
                            <label class="col-sm-2 col-sm-2 control-label">轮播图内容</label>
                            <div class="col-sm-10">
                                <!--1 商品 2资讯  3会员卡  4攻略课堂 5线上报名 6题库-->
                                <select id="status" name="status" class="form-control">
                                    <option value="1" <if condition="$list['status'] == 1">selected </if> >商品</option>
                                    <option value="2" <if condition="$list['status'] == 2">selected </if> >资讯</option>
                                    <option value="3" <if condition="$list['status'] == 3">selected </if> >会员卡</option>
                                    <option value="4" <if condition="$list['status'] == 4">selected </if> >攻略课堂</option>
                                    <option value="5" <if condition="$list['status'] == 5">selected </if> >线上报名</option>
                                    <option value="6" <if condition="$list['status'] == 6">selected </if> >题库</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">请选择要添加的轮播图的项目</label>
                            <div class="col-sm-10">
                                <select id="lun"  name="lun_id" class="form-control">
                                    <foreach name="types" item="v">
                                    <option value="{$v.id}"<if condition="$list['lun_id'] == $v['id']">selected </if> >{$v.name}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group" id="banner">
                            <label class="col-sm-2 col-sm-2 control-label">banner图<span style="color: red;">(750px*300px)</span></label>
                            <div class="col-sm-10">
                                <input type="file" name="one" id="avatar" onchange='PreviewImage(this)' style="opacity: 0;display: block;cursor:pointer" />
                                <if condition="$list.img != NULL">
                                   <img class="ph-user"  src="{$list.img}" width="190" height="180" onclick="openFile()" style="cursor:pointer">
                                   <else/>
                                   <img class="ph-user" src="__PUBLIC__/img/wutu.png" alt="" width="190" height="180" onclick="openFile()" style="cursor:pointer">
                               </if>
                               <!-- <img class="ph-user" src="__PUBLIC__/img/a11.png" alt="" width="190" height="180" onclick="openFile()" style="cursor:pointer">-->
                            </div>
                        </div>
                        <input type="hidden"  name="id" value="{$list.id}">
                        <input type="hidden"  name="img" value="{$list.img}">
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label"></label>
                            <div class="col-sm-10">
                                <input  type="submit" id="tianjia" class="btn btn-theme" value="保存" style="width: 150px;margin-left: 60px">
                                <input  type="reset" class="btn btn-warning" value="重置" style="width: 150px">
                            </div>
                        </div>
                    </form>
                </div>
            </div><!-- col-lg-12-->
        </div><!-- /row -->
    </section>
</section>
<!--footer-->
<include file="Public:footer"/>
<!--footer-->
<script type="text/javascript" src="__PUBLIC__/ui/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="__PUBLIC__/kindeditor/lang/zh_CN.js"></script>
<script>
    $("#status").change(function () {
        var status = $("#status").val();
        $.ajax({
            url:"{:U('lun')}",
            data:{status:status},
            type:"post",
            success:function (res) {
                $('#lun').html('');
                var arrs = "";
                if(res.info == 1){
                    arrs += "<option value='0'>暂无内容</option>"
                }else{
                    $.each(res.info,function(i,n){
                        arrs += "<option value="+n["id"]+">"+n['name']+"</option>"
                    });
                }
                $("#lun").append(arrs);
            }
        })
    })
    //编辑器
    var editor;
    KindEditor.ready(function(e){
        editor = e.create("[name=content]",{
            "width":"700px",
            "height":"300px",
            allowFileManager:true, //允许对上传图片进行管理
            "items":["source", "|", "undo", "redo", "|", "preview","|", "justifyleft", "justifycenter", "justifyright", "justifyfull", "insertorderedlist", "insertunorderedlist", "indent", "outdent", "subscript", "superscript", "clearhtml","|","formatblock", "fontname", "fontsize", "|", "forecolor", "hilitecolor", "bold", "italic", "underline","|", "image"]
        });
    });
    //图片上传
    function openFile(){
        return  $("#avatar").click();
    }

    function PreviewImage(imgFile)
    {
        var filextension=imgFile.value.substring(imgFile.value.lastIndexOf("."),imgFile.value.length);
        var o=imgFile.files[0];
        filextension=filextension.toLowerCase();
        if ((filextension!='.jpg')&&(filextension!='.jpeg')&&(filextension!='.png')&&(filextension!='.bmp')) {
            imgFile.focus();
        }else if(o.size > 2097152){
            imgFile.focus();
        } else {
            var path;
            path=window.URL.createObjectURL(imgFile.files[0]);// FF 7.0以上
            $('.ph-user').attr({src:path});
        }
    }


</script>

</body>
</html>


